class OpcodeLabels {
    constructor () {
        /**
         * Initial opcode map, with categories defined
         * @private
         */
        this._opcodeMap = {
            // Motion
            motion_direction: {category: 'motion', labelFn: () => "方向"},
            motion_xposition: {category: 'motion', labelFn: () => "x 坐标"},
            motion_yposition: {category: 'motion', labelFn: () => "y 坐标"},
            // Looks
            looks_size: {category: 'looks', labelFn: () => "大小"},
            looks_costumenumbername: {category: 'looks', labelFn: params => (params.NUMBER_NAME === 'number')?"造型编号":"造型名称"},
            looks_backdropnumbername: {category: 'looks',labelFn: params => (params.NUMBER_NAME === 'number')?"背景编号":"背景名称"},
            looks_backdropname: {category: 'looks', labelFn: () => "背景名称"},
            // Data
            data_variable: {category: 'data', labelFn: params => params.VARIABLE},
            data_listcontents: {category: 'list', labelFn: params => params.LIST},
            // Sound
            sound_volume: {category: 'sound', labelFn: () => "音量"},
            sound_tempo: {category: 'sound', labelFn: () => "演奏速度"},
            // Sensing
            sensing_answer: {category: 'sensing', labelFn: () => "回答"},
            sensing_loudness: {category: 'sensing', labelFn: () => "响度"},
            sensing_username: {category: 'sensing', labelFn: () => "用户名"},
            sensing_timer: {category: 'sensing', labelFn: () => "计时器"},
            sensing_current: {category: 'sensing', labelFn: params => {
                switch (params.CURRENTMENU.toLowerCase()) {
                case 'year':return  "年";
                case 'month':return "月";
                case 'date':return "日";
                case 'hour':return "时";
                case 'minute':return "分";
                case 'second':return "秒";
                case 'dayofweek':return "星期";
                }
            }}
        };
    }

    /**
     * Return the label for an opcode
     * @param {string} opcode the opcode you want a label for
     * @return {object} object with  label and category
     */
    getLabel (opcode) {
        if (opcode in this._opcodeMap) return this._opcodeMap[opcode];
        return {
            category: 'extension',
            label: opcode
        };
    }
}

export default new OpcodeLabels();
